package czk.jvm.lecture.memory;

public class MyTest3 {
    public static void main(String[] args){
        new Thread(()->A.test(),"thread_0").start();
        new Thread(()->B.test(),"thread_1").start();
    }
}
class A{
    public static synchronized void test() {
        System.out.println("A");
        try {
            Thread.sleep(300);
            B.test();
        }catch (Exception ex){
            ex.printStackTrace();
        }

    }
}
class B{
    public static synchronized void test()  {
        System.out.println("B");
        try {
            Thread.sleep(300);
            A.test();
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
